<?php get_header();?>
<!-- Dung cho trang tin tuc va trang dich vu -->
<style>
	.fixphotos
{
	padding:10px;
	background:#fff;
	overflow:hidden;
	margin-top:10px;	
}
	.fixphotos ul li
	{
		float:left;
		width:230px;
		margin:10px;
		
}
.fixphotos ul li input[type=text]
{
	border:1px solid silver;
	border-radius:3px;
	width:215px;
	height:22px;
}
</style>
<body>
<div id="container">
	<!-- baner -->
	<?php include TEMPLATEPATH.'/views/view-header.php';?>
	<!-- end banner-->
	<!-- menu -->
	<?php include TEMPLATEPATH.'/views/view-menu.php';?>
	<div class="body_content">
	<div id="content">
		
		<!-- left_comlumds -->
		<?php get_sidebar();?>
		<!--end left_comlumds -->
		<!-- right_comlumds -->
		<div class="right_comlumds">
		<div class="fixphotos">
		<form action="" method="post">
			<ul>
			<?php 
			//print_r($_POST);
			$sessionid = session_id();
			if(isset($_GET['postID']) && isset($_GET['si']) && $sessionid==$_GET['si'])
			{
				$post_id = $_GET['postID'];
				
				
				if(wp_verify_nonce($_POST['act_update_title_photos'],'act_update_title_photos'))
				{				
					$temp=0;
					foreach ($_POST['fix-photos'] as $value) 
					{
						$post_id = $_GET['postID'];
						update_post_meta($post_id, $wpdb->prefix.'title-fix-photo-'.$_POST['fix-photo-hidden'][$temp], $value);					
						$temp++;
					}
					?>
					<p style="color: red; width: 100%;"> Cập nhật thành công!</p>
					<?php 
				}
				
				$images = get_post_meta($post_id, $wpdb->prefix.'thumbnail2',false);
				if($images)
				{
					foreach ($images as $value) 
					{
					?>
					<li>						
						<?php echo db_get_thumbnail(db_get_attached_file($value), '', 220, 150);?>
						Tiêu đề:
						<br/>
						<input type="text" name="fix-photos[]" value="<?php echo get_post_meta($post_id,$wpdb->prefix.'title-fix-photo-'.$value,true);?>">
						<input type="hidden" name="fix-photo-hidden[]" value="<?php echo $value;?>">
					</li>
					<?php 		
					}
				}
			}
			
			?>	
			</ul>
			<div style="float: left; width: 100%;">
				<input type="submit" style="border: 1px solid silver; border-radius:3px; width:70px; height:24px; line-height:22px; color: #000; font-weight: bold;" value="Cập nhật">
			</div>
			<?php wp_nonce_field('act_update_title_photos','act_update_title_photos');?>
		</form>	
		</div>			
		</div>
		<!-- right_comlumds -->
	</div>
	<!-- end content-->
</div>
	<!-- end content-->
	<?php get_footer();?>
